package com.aeoj.clientmanagement.enums.pk;

import lombok.Getter;

/**
 * author: ZSM
 * time: 2025-04-23 21:44
 */
@Getter
public enum BattleResultEnum {
    LOSE(0, "输"),
    WIN(1, "赢"),
    DRAW(2, "平");

    private final int code;
    private final String desc;

    BattleResultEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code获取枚举实例
     */
    public static BattleResultEnum getByCode(int code) {
        for (BattleResultEnum value : values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        throw new IllegalArgumentException("无效的对战结果code: " + code);
    }
}
